<!--# layout("/common/layout.html",{"jsBase":"/js/customer/customerInfo/"}){ -->

<form class="layui-form layui-form-pane" id="addForm" enctype="multipart/form-data"  lay-filter="editform">
    <input type="hidden" name="customerId" id="customerId">

    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">会员id </label>
                <div class="layui-input-inline">
                                    <span style="line-height:38px;margin-left:8px">
                                        ${customerInfo.customerId}
                                    </span>
                </div>
            </div>
            <div class="layui-inline">
            <label class="layui-form-label">注册类型 </label>
				<div class="layui-input-inline">
                                    <span style="line-height:38px;margin-left:8px">
                                        ${customerInfo.regTypeText}
                                    </span>
				</div>
            </div>
            <div class="layui-inline">
            <label class="layui-form-label">appid</label>
				<div class="layui-input-inline">
                                    <span style="line-height:38px;margin-left:8px">
                                        ${customerInfo.appId}
                                    </span>
				</div>
            </div>
        </div>
    </div>

    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">来源渠道</label>
                <div class="layui-input-inline">
                                    <span style="line-height:38px;margin-left:8px">
                                        ${customerInfo.channelName}
                                    </span>
                </div>
            </div>
            <div class="layui-inline">
            <label class="layui-form-label">来源id</label>
				<div class="layui-input-inline">
                                    <span style="line-height:38px;margin-left:8px;white-space:nowrap;">
                                        ${customerInfo.sourceId}
                                    </span>
				</div>
            </div>
            <div class="layui-inline">
            <label class="layui-form-label">来源子id</label>
				<div class="layui-input-inline">
                                    <span style="line-height:38px;margin-left:8px">
                                        ${customerInfo.subSourceId}
                                    </span>
				</div>
            </div>

        </div>
    </div>
    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">来源模块</label>
                <div class="layui-input-inline">
                                    <span style="line-height:38px;margin-left:8px">
                                        ${customerInfo.moduleName}
                                    </span>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">微信昵称</label>
                <div class="layui-input-inline">
                                    <span style="line-height:38px;margin-left:8px">
                                        ${customerInfo.wxUname}
                                    </span>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">微信头像</label>
                <div class="layui-input-inline">
                    <img src="${customerInfo.wxPicurl}" height="40px">
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">定位名称</label>
                <div class="layui-input-inline">
                                    <span style="line-height:38px;margin-left:8px">
                                        ${customerInfo.locationName}
                                    </span>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">地图坐标</label>
                <div class="layui-input-inline">
                                    <span style="line-height:38px;margin-left:8px">
                                        ${customerInfo.locationPoint}
                                    </span>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">注册时间</label>
                <div class="layui-input-inline">
                    <span style="line-height:38px;margin-left:8px">
                    ${customerInfo.registerTime,"yyyy-MM-dd HH:mm:ss"}
                    </span>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">绑定手机号</label>
                <div class="layui-input-inline">
                    <span style="line-height:38px;margin-left:8px">
                        ${customerInfo.phone}
                    </span>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">会员类型</label>
                <div class="layui-input-inline">
                    <span style="line-height:38px;margin-left:8px">
                        ${customerInfo.customerType==0?"内部员工":"普通会员"}
                    </span>
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">推广码</label>
                <div class="layui-input-inline">
                    <span style="line-height:38px;margin-left:8px">
                        ${customerInfo.spCode}
                    </span>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-form-item">
            <!--#if(canAccess("customer.customerInfo.grant")){ /*功能*/ -->
            <button class="layui-btn layui-btn-danger" type="button" id="addButton" lay-submit lay-filter="form">授权</button>
            <button class="layui-btn layui-btn-danger" type="button" id="revokeButton" lay-submit lay-filter="form">取消授权</button>
            <!--# } -->
            <button class="layui-btn" type="button" id="addButton-cancel">取消</button>
        </div>
    </div>
</form>
<table id="customerRoleTable" lay-filter="customerRoleTable"></table>
<!--#} -->
<script>
    Common.initImage();
layui.define([ 'form', 'laydate', 'table','customerInfoApi'], function(exports) {
    var form = layui.form;
    var table = layui.table;
    var customerInfoApi = layui.customerInfoApi;
    var index = layui.index;
    var isNew = true;
    <!--# if(!(isEmpty(customerInfoJson))){  -->
    isNew = false;
    <!--# } -->
    var view = {
        init:function(){
            Lib.initGenrealForm($("#addForm"),form);
            this.initSubmit();
            window.dataReload = function () {
                window.location.reload();
            }
        },
        initSubmit:function(){
            $("#addButton").click(function(){
                var url = "/customer/customerInfo/grantCustomer.do?customerId=${customerInfo.customerId}";
                var title = "会员授权管理>${customerInfo.customerName}";
                Common.openDlg(url,title);
            });
            $("#revokeButton").click(function(){
                var data = Common.getOneFromTable(table, "customerRoleTable");
                if (data == null) {
                    return;
                }
                var url = "/customer/customerInfo/revokeCustomer.json?customerId=${customerInfo.customerId}&rightId="+data.rightId;
                Common.post(url, {}, function () {
                    dataReload();
                })
            });
            $("#addButton-cancel").click(function(){
                Lib.closeFrame();
            });
        }

    }
    view.init();
    <!--# if(!(isEmpty(customerInfoJson))){  -->
    var formJson = ${customerInfoJson};
    form.val("editform",formJson);
    $(".image-preview").each(function() {
        $(this).attr("src",formJson[$(this).attr("id")]);
    });
    customerRoleTable = table.render({
        elem: '#customerRoleTable',
        height: Lib.getTableHeight(0),
        cellMinWidth: 100,
        method: 'post',
        url: Common.ctxPath + '/customer/customerInfo/roleList.json?customerId=${customerInfo.customerId}' // 数据接口
        , page: false
        ,cols: [[ // 表头
            {
                type: 'checkbox',
                fixed: 'left',
            },
            {
                field: 'roleName',
                title: '权限',
            },
            {

                field: 'rightStatus',
                title: '权限状态',
                templet: '<div>{{d.rightStatus==1?"有效":d.rightStatus==2?"待激活":"失效"}}</div>'
            },
            {

                field: 'onceOnly',
                title: '是否一次性',
                templet: '<div>{{d.onceOnly==1?"是":"否"}}</div>'
            },
            {
                field: 'expiredDate',
                title: '失效日期',
            },
            {

                field: 'createTime',
                title: '生成时间',
            }
        ]]

    });
    <!--# } -->
});
</script>
